package cate.game.play.skill.passive.exp;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 每次受击有20%概率提升自身15%防御，若触发格挡或闪避，概率提升至100%
 */
public class 浩然正气PH extends PassiveHandler {

	private int 基础概率;

	private int 触发概率;

	private int buff;

	//基础概率=2000&触发概率=8000&buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		基础概率 = args.getInt("基础概率", 0);
		触发概率 = args.getInt("触发概率", 0);
		buff = args.getInt("buff", 0);
	}


	@Override
	public void onMissAsTarget(SkillActionCtx action) {
		skill.owner.buff.tryAddByTid(action, skill.owner, buff, 触发概率);
	}

	@Override
	public void afterSufferOneAttack(SkillActionCtx action, long totalDamage, boolean strike) {
		int chance = 基础概率;
		if (action.getStat().isParry(skill.owner.getPid())) {
			chance = 触发概率;
		}
		skill.owner.buff.tryAddByTid(action, skill.owner, buff, chance);
	}
}
